﻿//
// Copyright (c) 2010
// by Chris Paterra
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.ComponentModel;
using System.Web.UI.WebControls;

namespace DotNetNuke.ContentLibrary.Components.WebControls 
{

	/// <summary>
	/// 
	/// </summary>
	/// <remarks>All public properties in this class are required to be set in all consuming projects.</remarks>
	public class ControlBase : CompositeControl {

		/// <summary>
		/// The content item we are associating the implemented  control with.
		/// </summary>
		[Browsable(false)]
		public int CurrentContentItemID {
			get {
				var contentItemID = 0;
				if (ViewState["CurrentContentItemID"] != null) {
					contentItemID = Convert.ToInt32(ViewState["CurrentContentItemID"]);
				}
				return contentItemID;
			}
			set { ViewState["CurrentContentItemID"] = value; }
		}

		/// <summary>
		/// The current user accessing the control.
		/// </summary>
		[Browsable(false)]
		public int CurrentUserID {
			get {
				var userID = 0;
				if (ViewState["CurrentUserID"] != null) {
					userID = Convert.ToInt32(ViewState["CurrentUserID"]);
				}
				return userID;
			}
			set { ViewState["CurrentUserID"] = value; }
		}

		/// <summary>
		/// The current portal the user is accessing this control through.
		/// </summary>
		[Browsable(false)]
		public int PortalID {
			get {
				var portalID = 0;
				if (ViewState["PortalID"] != null) {
					portalID = Convert.ToInt32(ViewState["PortalID"]);
				}
				return portalID;
			}
			set { ViewState["PortalID"] = value; }
		}

		/// <summary>
		/// This provides a full path to the shared resource file for localization. 
		/// </summary>
		internal string SharedResourceFile
		{
			get { return ResolveUrl("~/DesktopModules/ContentLibrary/App_LocalResources/SharedResources.resx"); }
		}

	}
}